<template>
  <el-form label-width="80px" :model="formData" :rules="rules">
    <el-form-item label="表单名称" prop="name">
      <el-input v-model="formData!.name" placeholder="请输入" maxlength="64" />
    </el-form-item>
    <el-form-item label="表单描述" prop="description">
      <el-input v-model="formData!.description" type="textarea" :rows="5" maxlength="512" show-word-limit placeholder="请输入" />
    </el-form-item>
  </el-form>
</template>

<script lang="ts" setup>
import { FormConfigBaseInfo } from './config'
import { usePropertyForm } from '../index'

const props = defineProps<{ modelValue: FormConfigBaseInfo }>()
const emit = defineEmits(['update:modelValue'])
const { formData } = usePropertyForm(props.modelValue, emit)
// 表单校验
const rules = {
  name: [
    { required: true, message: '表单名称不能为空', trigger: 'blur' },
    { min: 1, max: 64, message: '字数请在64字以内' }
  ],
  description: [
    { min: 1, max: 512, message: '字数请在512字以内' }
  ],
}
</script>
